﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary

<Serializable()> Public Class PostFile
    Implements ICloneable
    Private m_IsPost As Boolean = True

    Private m_PolluteName As String
    Private m_GroupName As String
    Private m_AervarageTime As String
    Private m_FileName As String
    
    Property IsPost() As Boolean
        Get
            Return m_IsPost
        End Get
        Set(ByVal value As Boolean)
            m_IsPost = value
        End Set
    End Property
    ''' <summary>
    ''' 污染物名称
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property PolluteName() As String
        Get
            Return m_PolluteName
        End Get
        Set(ByVal value As String)
            m_PolluteName = value
        End Set
    End Property
    ''' <summary>
    ''' 污染源分组
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GroupName() As String
        Get
            Return m_GroupName
        End Get
        Set(ByVal value As String)
            m_GroupName = value
        End Set
    End Property
    ''' <summary>
    ''' 平均时间
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property AervarageTime() As String
        Get
            Return m_AervarageTime
        End Get
        Set(ByVal value As String)
            m_AervarageTime = value
        End Set
    End Property

    ''' <summary>
    ''' 对应的文件名和路径
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property FileName() As String
        Get
            Return m_FileName
        End Get
        Set(ByVal value As String)
            m_FileName = value
        End Set
    End Property

    ''' <summary>
    ''' 输出逐步值文件
    ''' </summary>
    ''' <param name="Control"></param>
    ''' <param name="Groups"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function OutPutPostFile(ByVal Control As Control, ByVal Groups As Groups) As String
        Dim GroupId As String = ""
        For i As Integer = 0 To Groups.ArrayGroup.Length - 1
            If Groups.ArrayGroup(i).Name = Me.m_GroupName And Groups.ArrayGroup(i).IsZero = False Then
                GroupId = Groups.ArrayGroup(i).GroupID
            End If
        Next
        Dim Time As String = ""
        For i As Integer = 0 To Control.AerageingTime.GetSelectedAerageingTime.Length - 1
            For j As Integer = 0 To Groups.ArrayGroup.Length - 1
                If Control.AerageingTime.GetSelectedAerageingTime(i) = Me.m_AervarageTime And Groups.ArrayGroup(j).IsZero = False Then
                    Time = Control.AerageingTime.GetSelectedAerageingTimeToAREMOD(i)
                End If
            Next
        Next
        If GroupId <> "" And Time <> "" Then
            Dim strO As String = ""
            strO = strO & "OU POSTFILE  " & Time & "  " & GroupId & "  PLOT  " & Me.m_FileName & vbCrLf
            Return strO
        End If
        Return ""
    End Function

    Public Function OutPutCarePostFile(ByVal Control As Control, ByVal index As Integer, ByVal Groups As Groups, ByVal ProjName As String) As String
        '只输出1小时或24小时的浓度
        Dim strPost As String = ""
        If m_IsPost Then
            For nGroups As Integer = 0 To Groups.ArrayGroup.Length - 1
                For nTime As Integer = 0 To Control.AerageingTime.GetSelectedAerageingTime.Length - 1
                    strPost = strPost & "OU POSTFILE  " & Control.AerageingTime.GetSelectedAerageingTimeToAREMOD(nTime) & " " & Groups.ArrayGroup(nGroups).GroupID & " UNFORM  Aermod\" & ProjName & "\" & Groups.ArrayGroup(nGroups).GroupID & "_POST_" & Control.AerageingTime.GetSelectedAerageingTime(nTime) & ".BIN" & vbCrLf
                Next
            Next
        End If
        Return strPost
    End Function
    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj As New PostFile
        obj.m_IsPost = Me.m_IsPost
        obj.m_PolluteName = Me.m_PolluteName
        obj.m_GroupName = Me.m_GroupName
        obj.m_AervarageTime = m_AervarageTime
        obj.m_FileName = m_FileName
        Return obj
    End Function
End Class
